# pages/login_page.py
from pages.base_page import BasePage
from utils.config import ConfigManager
import time

class LoginPage(BasePage):
    def perform_login(self):
        """执行完整登录流程"""
        self._accept_agreement()
        self._enter_login_page()
        self._input_credentials()
        self._handle_post_login()
        
    def _accept_agreement(self):
        self.click_element('agree_button')
        self.click_element('continue_button')
        time.sleep(2)
        
    def _enter_login_page(self):
        self.click_element('login_tab')
        time.sleep(1)
        
    def _input_credentials(self):
        creds = ConfigManager().credentials
        self.input_text('username_field', creds['username'])
        self.input_text('password_field', creds['password'])
        self.click_element('agreement_checkbox')
        self.click_element('login_button')
        time.sleep(3)
        
    def _handle_post_login(self):
        self.click_element('enter_device_button')
        self.click_element('location_permission_close')
        time.sleep(5)